/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-28
 * Time: 18:07
 */
public class Demo1 {
    public static int count=0;
    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();

       Thread thread=new Thread(()->{
           for (int i = 0; i < 50000; i++) {
               synchronized (locker){
                   count++;
               }
           }
       });
       Thread thread2=new Thread(()->{
           for (int i = 0; i <50000 ; i++) {
               synchronized (locker){
                   count++;
               }
           }
       });
       thread.start();
       thread2.start();
       thread.join();
       thread2.join();
        System.out.println("count= "+count);
    }
}
